<?php /*

**************************************************************************

Plugin Name:  Print User
Plugin URI:   
Description:  Imprime los datos de usuario en HTML en una page utilizando un shortcode [print-user]
Version:      0.1
Author:       Carlos Araujo
Author URI:   http://www.estudioduplex.com

**************************************************************************/

add_shortcode('print-user', 'f_print_user');

function f_print_user(){
	
	$user_id = $_GET["user_id"];
	$user_info = get_userdata( $user_id );

	$first_name = $user_info-> user_firstname;
	$last_name = $user_info-> user_lastname;
	$email = $user_info-> user_email;
	$telefono = $user_info-> telefono;
	$curriculum = $user_info-> curriculum;

?>
	
	

<?php	
	return "<hr /><h2>$first_name $last_name</h2>
		<h4>Email</h4>$email 
		<h4>Tel&eacute;fono</h4>$telefono
		<h4>Curriculum</h4>$curriculum";
}

//Agrega el botton de print-friendly

add_shortcode('print-friendly', 'f_print_friendly');

function f_print_friendly(){?>

	<script>var pfHeaderImgUrl = '';var pfHeaderTagline = '';var pfdisableClickToDel = 0;var pfHideImages = 1;var pfImageDisplayStyle = 'right';var pfDisablePDF = 0;var pfDisableEmail = 0;var pfDisablePrint = 1;var pfCustomCSS = '';var pfBtVersion='1';(function(){var js, pf;pf = document.createElement('script');pf.type = 'text/javascript';if('https:' == document.location.protocol){js='https://pf-cdn.printfriendly.com/ssl/main.js'}else{js='http://cdn.printfriendly.com/printfriendly.js'}pf.src=js;document.getElementsByTagName('head')[0].appendChild(pf)})();</script>
	<a href="http://www.printfriendly.com" style="color:#6D9F00;text-decoration:none;" class="printfriendly" onclick="window.print();return false;" title="Printer Friendly and PDF"><img style="border:none;-webkit-box-shadow:none;box-shadow:none;" src="http://cdn.printfriendly.com/pf-button-both.gif" alt="Print Friendly and PDF"/></a>	
<?php	
}



//Link en espacio de administracion a la página de datos del usuario
//Sólo se imprime para el administrador
add_action('edit_user_profile', 'add_extra_profile_fields');

function add_extra_profile_fields( $user ) {
	$user_id = $_GET["user_id"];
	$href = get_bloginfo('url').'/datos-personales-consulta?user_id='.$user_id;
	
	$user_info = get_userdata($user_id);
    $first_name = $user_info-> user_firstname;
    $last_name = $user_info-> user_lastname;
?>
	<h3>Datos personales ampliados</h3>
	<table class="form-table">
		<tbody>
			<tr>
				<th><label>Link a la información</label></th>
				<td><a href="<?php echo $href ?>">Info de <?php echo $first_name.' '.$last_name ?></a></td>
			</tr>
		</tbody>
	</table>	
	
<?php }

?>